using System;
using System.Drawing;
using System.Collections.Generic;
using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace Beauty.Module.Pos
{
    public partial class PackagesVCtrl : UIViewController
    {
		 
		List<packageItem> listPackagesItem;
		static bool isGrid = false;
        public PackagesVCtrl()
            : base("PackagesVCtrl", null)
        {
			listPackagesItem = new List<packageItem> ();

			for (int i = 0; i < 12; i++) {
				var packageItem = new packageItem ();
				listPackagesItem.Add (packageItem);
			}
        }
		static NSString tableProductCellId = new NSString("tableCell");
		static NSString gridProductCellId = new NSString("gridCell");
        public override void DidReceiveMemoryWarning()
        {
            // Releases the view if it doesn't have a superview.
            base.DidReceiveMemoryWarning();

            // Release any cached data, images, etc that aren't in use.
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
			 


			packageCollection.Layer.BorderWidth = 1f;

			packageCollection.Layer.BorderColor = UIColorExtensions.FromHexString("#b2b2b2").CGColor;

			packageCollection.RegisterClassForCell (typeof(packageCell), gridProductCellId);
			packageCollection.RegisterClassForCell (typeof(packageCellList), tableProductCellId);
			packageCollection.RegisterClassForSupplementaryView (typeof(Header1), UICollectionElementKindSection.Header, new NSString ("Header"));
			packageCollection.RegisterClassForSupplementaryView (typeof(Footer1), UICollectionElementKindSection.Footer, new NSString ("Footer"));

			cmdChange.TouchUpInside += (object sender, EventArgs e) => {
				changeLayout ();

			}; 
		 


			UIView viewRight = new UIView (new RectangleF(660, 20, 340, 650));
			viewRight.Layer.CornerRadius = 5f;
			viewRight.BackgroundColor = UIColor.White;
			UIView viewRightTop = new UIView (new RectangleF(0, 0, 340, 50));
			viewRightTop.BackgroundColor = UIColorExtensions.FromHexString ("#a1a1a1");
			UIImage imageCreate = UIImage.FromFile ("ic_createjs.png");
			UIButton cmdCreate = new UIButton (UIButtonType.Custom);
			cmdCreate.SetBackgroundImage (imageCreate, UIControlState.Normal);
			cmdCreate.Frame = new RectangleF (290, 0, 50, 50);



			UIImageView  imagePay = new UIImageView( UIImage.FromFile ("bt_pay0.png"));
			imagePay.Frame = new RectangleF (20, 580, 300, 50);

			UILabel lbTotal = new UILabel (new RectangleF (150, 590, 250, 30));
			lbTotal.Text = "Pay $0";
			lbTotal.TextColor = UIColor.White;
			UIView line = new UIView (new RectangleF (0, 550, 340, 1));



			line.BackgroundColor = UIColorExtensions.FromHexString ("#b2b2b2");


			View.BackgroundColor = UIColorExtensions.FromHexString ("#ebeef0");
			viewRight.Layer.BorderWidth = 1f;
			viewRight.Layer.BorderColor = UIColorExtensions.FromHexString("#b2b2b2").CGColor;


			viewRight.AddSubview (viewRightTop);
			viewRight.AddSubview (cmdCreate);
			viewRight.AddSubview (imagePay);
			viewRight.AddSubview (lbTotal);
			viewRight.AddSubview (line);
		 
			View.Add (viewRight);
        }
		public override void ViewWillAppear (bool animated)
		{
			base.ViewWillAppear (animated);
			packageCollection.SetCollectionViewLayout (new productLayout (), true);
			packageCollection.Source = new packagesCollectionSource (listPackagesItem ,0);

		}
		public void changeLayout ()
		{
			if (!isGrid) {
				packageCollection.SetCollectionViewLayout (new productLayoutList (), false);
				packageCollection.Source = new packagesCollectionSource (listPackagesItem, 1);
				cmdChange.SetTitle ("Grid", UIControlState.Normal);
				isGrid = true;
			} else {
				packageCollection.SetCollectionViewLayout (new productLayout (), false);
				packageCollection.Source = new packagesCollectionSource (listPackagesItem, 0);
				cmdChange.SetTitle ("List", UIControlState.Normal);
				isGrid = false;
			}
		}
    }
}